<template>
	<view class="content">
		
		<div class="rounded-rectangle-container">
		    <div class="rounded-rectangle">
				<div class="avatar-container">
					<!-- <image style="width: 155px;height: 105px;position: relative;left: 140px;top:50px;" src="/static/货车.png"> -->
				        <div class="avatar-border" >
				            <div class="avatar-background">
								<image class="logo" src="/static/用户.png">
				            </div>
							<div style="margin-top:15px;font-size:20px;font-weight: bold;width: 80px;" >{{userName}}</div>
							<div style="margin-top:8px;font-size:12px;font-family: 黑体;width: 80px;" @click="navigateToUser">更多用户设置></div>
				        </div>
				    </div>
		    </div>
		  </div>
		  <div class="centered-div">- 操作 -<button type="default" @click="sign()" style="position: absolute;right: 20px;font-size: 14px;font-weight: bold;">补签操作</button></div>
		  <div class="container">
		    <div class="square">
				<img class="pict" src="/static/编辑.png" @click="navigateTocheck">
				<div style="font-size:12px;margin-top: 5px;">账单管理</div>
			</div>
		    <div class="square" @click="navigateToAbnormal">
				<img class="pict" src="/static/提醒.png"  >
				<div style="font-size:12px;margin-top: 5px;">服务订单</div>
			</div>
		    <div class="square" @click="navigateToMistake"> 
				<img class="pict" src="/static/转发.png" >
				<div style="font-size:12px;margin-top: 5px;">服务记录</div>
			</div>
		  </div>
		  <div class="container2">
			  <div class="rectangle"  @click="navigateToOrder">
			  	<img src="/static/订单.png" alt="Icon"  class="circle-image">
			  	<span class="rectangle-text" >预约</span>
			  	<span class="rectangle-small" style="margin-left: 20px;" >共{{items.appointmentNo}}单记录</span>
			  </div>
		    <div class="rectangle"  @click="navigateToAll">
				<img src="/static/卡车.png" alt="Icon"  class="circle-image">
				<span class="rectangle-text">全部运单</span>
				<span class="rectangle-small">共{{items.wayBilNo}}单记录</span>
				
			</div>
			<div class="rectangle"  @click="navigateToTihuo">
				<img src="/static/订单.png" alt="Icon"  class="circle-image">
				<span class="rectangle-text" >提货</span>
				<span class="rectangle-small" style="margin-left: 20px;">共{{items.tiHuoNo}}单记录</span>
			</div>
			<div class="rectangle" @click="navigateToBill">
				<img src="/static/统计.png" alt="Icon"  class="circle-image">
				<span class="rectangle-text" >师傅分单</span>
				<span class="rectangle-small">共{{items.shifuNo}}单记录</span>
			</div>
		    <div class="rectangle"  @click="navigateToSign">
				<img src="/static/订单.png" alt="Icon"  class="circle-image">
				<span class="rectangle-text" >签收</span>
				<span class="rectangle-small" style="margin-left: 20px;">共{{items.signNo}}单记录</span>
			</div>
		    <div class="rectangle" @click="navigateToIndividual">
				<img src="/static/统计.png" alt="Icon"  class="circle-image">
				<span class="rectangle-text" style="margin-left: -10px;">分单统计</span>
			</div>
		  </div>
	</view>
</template>

<script>
	import {getCount} from '@/api/login.js';
	export default {
		data() {
			return {
				title: '首页',
				userName:'',
				items:{}
			}
		},
		onLoad(options) {
				 console.log(options.selectedOption)
				this.userName=options.userName
				this.phone=options.phone
				this.userId=options.userId
				this.subaccount=options.subaccount
				uni.setStorageSync("userName",this.userName)
					// if(options.value==1){
			  //         this.selectedTab = "预约"
					// }
					// if(options.value=2){
					// 	this.selectedTab = "签收"
					// }
		},
		mounted(){
			getCount({contactInformation:this.phone}).then(res=>{
				this.items=res.data.data
			})
		},
		methods: {
			sign(){
				uni.navigateTo({
					url: '/pages/index/controls/controls?phone='+this.phone+'&subaccount='+this.subaccount+'&userId='+this.userId// 请注意，这里的url应为相对路径，且以'/'开头
				});
			},
			navigateToAll(){
				uni.navigateTo({
					url: '/pagesA/index/order/order?value=0&phone='+this.phone+'&subaccount='+this.subaccount+'&userId='+this.userId// 请注意，这里的url应为相对路径，且以'/'开头
				});
			},
			navigateToTihuo(){
				uni.navigateTo({
					url: '/pagesA/index/order/order?value=2&phone='+this.phone+'&subaccount='+this.subaccount+'&userId='+this.userId// 请注意，这里的url应为相对路径，且以'/'开头
				});
			},
			navigateToAbnormal(){
				uni.navigateTo({
						url: '/pagesA/index/abnormalOrder/abnormalOrder?phone='+this.phone+'&userId='+this.userId // 请注意，这里的url应为相对路径，且以'/'开头
				});
			},
			navigateToMistake(){
				uni.navigateTo({
						url: '/pagesA/index/mistake/mistake?phone='+this.phone+'&userId='+this.userId // 请注意，这里的url应为相对路径，且以'/'开头
				});
			},
			navigateToUser() {
			  uni.navigateTo({
				url: '/pagesA/index/user/user?userName='+this.userName+'&phone='+this.phone+'&userId='+this.userId+'&subaccount='+this.subaccount // 请注意，这里的url应为相对路径，且以'/'开头
			  });
			   // this.$router.push('/user'); // Vue Router
			},
			navigateToOrder(){
				if(this.selectedOption==='司机端'){
				uni.showToast({
					        title: '您没有权限，请联系管理员',
					        icon: 'none',
					    });
					return ; // 如果为空，则不执行后续操作
				}else{
				uni.navigateTo({
					url: '/pagesA/index/order/order?value=1&phone='+this.phone+'&subaccount='+this.subaccount+'&userId='+this.userId// 请注意，这里的url应为相对路径，且以'/'开头
				});
				}
			},
			navigateToSign(){
				uni.navigateTo({
					url: '/pagesA/index/order/order?value=3&phone='+this.phone // 请注意，这里的url应为相对路径，且以'/'开头
				});
			},
			navigateToBill(){
				if(this.subaccount==='true'){
					uni.showToast({
					        title: '您没有权限，请联系管理员',
					        icon: 'none',
					    });
					return ; // 如果为空，则不执行后续操作
					console.log('权限不足，已返回');
				}else{
				  uni.navigateTo({
				  	 url: '/pagesA/index/bill/bill?phone='+this.phone+'&userId='+this.userId // 请注意，这里的url应为相对路径，且以'/'开头
				  });
				}
			},
			navigateToIndividual(){
				if(this.subaccount==='true'){
					uni.showToast({
					        title: '您没有权限，请联系管理员',
					        icon: 'none',
					    });
					return ; // 如果为空，则不执行后续操作
				}else{
				  uni.navigateTo({
				  	url: '/pagesA/index/individual/individual?phone='+this.phone+'&userId='+this.userId // 请注意，这里的url应为相对路径，且以'/'开头
				  	});
				}
			},
			navigateTocheck(){
				if(this.subaccount==='true'){
					uni.showToast({
					        title: '您没有权限，请联系管理员',
					        icon: 'none',
					    });
					return ; // 如果为空，则不执行后续操作
				}else{
				  uni.navigateTo({
				  	url: '/pagesA/index/check/check?phone='+this.phone+'&userId='+this.userId // 请注意，这里的url应为相对路径，且以'/'开头
				  });
				}
			},
		}
	}
</script>

<style>
	@import "index.css";
</style>
